<template>
    <el-card>
        <el-form :model="queryParams" ref="queryParams" :inline="true" label-width="120px">
            <el-form-item label="专线业务：" prop="name">
                <el-input v-model="queryParams.name" placeholder="名称" size="small"></el-input>
            </el-form-item>
             <el-form-item label="专线类型：" prop="type">
                 <el-select v-model="queryParams.type" placeholder="请选择" size="small">
                    <el-option v-for="item in typeArr" :label="item.label" :key="item.value" :value="item.value"></el-option>
                  </el-select>
            </el-form-item>
            <el-form-item >
                <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-delete" size="small" @click="resetQuery('queryParams')">清空</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10">
            <el-col :span="24">
                <div style="margin-bottom: 10px">
                    <el-button type="primary" icon="el-icon-plus" size="small" @click="handleAdd">新增</el-button>
                </div>
            </el-col>
        </el-row>
        <el-table :data="tableData" border style="width: 100%" size="small">
            <el-table-column type="index" label="#" width="50"></el-table-column>
            <el-table-column label="专线业务" prop="name"></el-table-column>
            <el-table-column label="专线类型" prop="description"></el-table-column>
            <el-table-column label="是否公开" prop="description"></el-table-column>
            <el-table-column label="文档集" prop="description"></el-table-column>
            <el-table-column label="联系邮箱" prop="description"></el-table-column>
            <el-table-column label="创建时间" prop="description"></el-table-column>
            <el-table-column label="更新时间" prop="description"></el-table-column>
            <el-table-column label="操作" width="200" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">修改</el-button>
                    <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDel(scope.row.id)">删除</el-button>
                    <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
                </template>
            </el-table-column>
        </el-table>
         <el-pagination
                v-show="total>0"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                background
                :current-page="1"
                :page-sizes="[10, 20, 30, 40,50,100]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                class="pagination-container"
                :total="total">
        </el-pagination>
   </el-card>
</template>

<script>
import { getAuthList } from '@/api/interface/auth.api'
    export default {
        data() {
          return {
            queryParams: {
                current: 1,
                size: 10,
                name: undefined,
                description: undefined,
            },
            tableData: [],
            total: 0,
            typeArr: [
                {label: '接口专线',value: 1},
                {label: '网站专线',value: 2},
            ]
          }
        },
        mounted() {
            this.getList();
        },
        methods: {
            handleAdd() {
                this.$router.push('/public-network/business/add');
            },
            async getList() {
                const result = await getAuthList(this.queryParams);
                if(result.code === 200) {
                    this.tableData = result.data.records;
                    this.total = result.data.total
                }
            },
              // 搜索
            handleQuery() {
                this.queryParams.current = 1;
                this.getList();
            },
            // 清空
            resetQuery(formName) {
                this.$refs[formName].resetFields();
                this.getList();
            },
            handleSizeChange(val) {
                this.queryParams.size = val;
                this.getList();
            },
            handleCurrentChange(val) {
                this.queryParams.current = val;
                this.getList();
            },
        }
    }
</script>
<style lang="scss" scoped>
.pagination-container {
    padding: 10px;
    text-align: right;
}
</style>